<template>
	<view class='content'>
		<view style='height: 10px;'></view>
		<!-- <u-cell-group class='top'>
			<u-cell  title="收款方式" isLink>
				<view
					slot="value"
					class="u-slot-value"
				>
					<picker @change="bindPickerChange" :value="index" :range="list" range-key='name'>
						<view class="uni-input">{{list[index].name}}</view>
					</picker>
				</view>
			</u-cell>
		</u-cell-group> -->
		<view class="cash">
			<view class="title">
				提现金额
			</view>
			<view class="form">
				<u--form
						labelPosition="left"
						:model="model1"
						:rules="rules"
						labelWidth='80px'
						ref="uForm"
				>
					<u-form-item
							label=""
							prop="money"
							borderBottom
							ref="item1"
					>
						<u--input
								type='number'
								prefixIcon="rmb"
								v-model="model1.money"
								placeholder="请输入提现金额"
								border="none"
						></u--input>
					</u-form-item>
					
					
				</u--form>
			</view>
			<view class="desc">
				可提现金额{{ ruleQuery.money }}元
			</view>
			<view class="flex">
				<u-checkbox-group
				    
					class="desc"
					v-model="checkboxValue1"
					placement="column"
					@change="checkboxChange"
				>
					
						<u-checkbox
							label=""
							name="1"
						>
						</u-checkbox>
						
					
				</u-checkbox-group>
				<view class='text' @click="gotoRule">
					请阅读提现规则
				</view>
			</view>
			
		</view>
		
		
		<view class="btn">
			<u-button type="primary" :disabled='checkboxValue1.length == 0' text="确定" @click='submit'></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				model1: {
					money: ''
				},
				rules: [],
				list: [],
				show: false,
				index: 0,
				ruleQuery: {
					money: '',
					rule: ''
				},
				userInfo: {},
				checkboxValue1: []
			}
		},
		onLoad() {
			
		},
		mounted() {
			this.getlist()
			this.getrule()
		},
		methods: {
			gotoRule(){
				uni.navigateTo({
					url: '/pages/jifen/integralRule'
				})
			},
			checkboxChange(n) {
				console.log('change', n);
				this.checkboxValue1 = n
			},
			getlist(){
				var _this = this
				this.fq_post('wxsite/User/userImgv2', {
					
				}, (res) => {
					console.log(res)
					if(res.code == 1){
						_this.userInfo = res.data
					}
				})
				// uni.request({
				// 	url: 'http://www.yndzfl.cn/wxsite/User/userImgv2',
				// 	method: 'POST',
				// 	header:{
				// 		"Content-Type" : "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		openid: uni.getStorageSync('OPENID')
				// 	},
				// 	success(res) {
				// 		if(res.data.code == 1){
				// 			_this.userInfo = res.data.data
							
							
				// 		}
						
				// 	}
				// })
			},
			bindPickerChange(e){
				// this.show = true
				console.log(e)
				this.index = e.detail.value
			},
			getrule(){
				
				var _this = this
				this.fq_post('wxsite/User/ruleWithdrawal', {
					
				}, (res) => {
					console.log(res)
					if(res.code == 1){
						_this.ruleQuery = res.data
					}
				})
				// uni.request({
				// 	url: 'http://www.yndzfl.cn/wxsite/User/ruleWithdrawal',
				// 	method: 'POST',
				// 	header:{
				// 		"Content-Type" : "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		openid: uni.getStorageSync('OPENID')
				// 	},
				// 	success(res) {
				// 		if(res.data.code == 1){
				// 			_this.ruleQuery = res.data.data
				// 		}
						
				// 	}
				// })
			},
			submit(){
				if( this.model1.money == "" ){
				  uni.showToast({
				  	title: '请输入提现金额',
					icon: 'none'
				  })
				  return
				}
				if( this.model1.money < parseFloat(this.ruleQuery.rule) ){
					 uni.showToast({
						title: `提现金额不能小于${this.ruleQuery.rule}元`,
						icon: 'none'
					 })
					return
				}
				
				if( this.model1.money > parseFloat(this.ruleQuery.money) ){
				  uni.showToast({
					title: `最多只能提现${this.ruleQuery.money}元`,
					icon: 'none'
				  })
				  return
				}
				if(this.checkboxValue1.length == 0){
					uni.showToast({
						title: '请勾选提现规则',
						icon: 'none'
					})
					return
				}
				this.presentation()
				
			},
			presentation(){
				
				var _this = this
				this.fq_post('wxsite/User/presentation', {
					money: _this.model1.money,
					userName: _this.userInfo.nickname,
					tel: _this.userInfo.mobile,
					Img: _this.userInfo.head_img,
					type: 2
				}, (res) => {
					console.log(res)
					if(res.code == 1){
						uni.navigateTo({
							url: '/pages/jifen/cashlist'
						})
					}
				})
				// uni.request({
				// 	url: 'http://www.yndzfl.cn/wxsite/User/presentation',
				// 	method: 'POST',
				// 	header:{
				// 		"Content-Type" : "application/x-www-form-urlencoded"
				// 	},
				// 	data: {
				// 		openid: uni.getStorageSync('OPENID'),
				// 		money: _this.model1.money,
				// 		userName: _this.userInfo.real_name,
				// 		tel: _this.userInfo.mobile,
				// 		Img: _this.userInfo.head_img,
				// 		type: 2
				// 	},
				// 	success(res) {
				// 		if(res.data.code == 1){
				// 			uni.navigateTo({
				// 				url: '/pages/jifen/cashlist'
				// 			})
				// 		}
						
				// 	}
				// })
			}
		}
	}
</script>

<style scoped>
.content{
	min-height: 100vh;
	background: #f6f6f6;
}
.top{
	background-color: #fff;
	margin: 0px 0 10px 0;
}
.cont{
	/* background-color: #fff; */
}
.cont-item{
	background-color: #fff;
	margin-top: 10px;
}
.upload{
	padding: 15px;
}
.cash{
	background-color: #fff;
}
.title{
	padding: 10px;
	color: #999;
}
.form{
	padding: 20px;
}
.desc{
	font-size: 14px;
	padding:0 15px 10px;
	color: #999;
}
.btn{
	margin: 20px;
}
.flex{
	display: flex;
	align-items: center;
}
.text{
	padding: 0 0px 10px;
	font-size: 15px;
}
</style>
